﻿<%@ Page Language="C#" MasterPageFile="~/Views/Shared/CalcOut.Master" Inherits="System.Web.Mvc.ViewPage<CallMVC.Models.LoginModel>" %>

<asp:Content ID="calcOutTitle" ContentPlaceHolderID="Title" runat="server">

<%
      DBManager.Customer cust = ViewBag.Customer;
%>

   <a href="<%: Url.Action("Calculation", "Home", new { customerId = cust.CustomerID })%>"><img src="/CalcApp/images/<%= cust.LogoLink %>" /></a>
</asp:Content>

<asp:Content ID="calcOutContent" ContentPlaceHolderID="MainContent" runat="server">
<% 
    using (Html.BeginForm())
    { 
%>
    <%: Html.ValidationSummary()%>

    <ul data-role="listview" data-inset="true">
        <li data-role="fieldcontain"> Calculation : <%: Html.Label(((DBManager.Calculation)this.ViewBag.Calculation).CalculationID)%> </li> 
    </ul>

<%
        int orderStatus = this.ViewBag.OrderStatus;
        if (orderStatus == 2)
        {             
        DBManager.Calculation calc = (DBManager.Calculation)this.ViewBag.Calculation;
        string myOrderId = (string)this.ViewBag.OrderId;

        foreach (DBManager.OutputDesignGroup group in calc.OutputDesignGroupsList)
        {
       
%>
    <ul data-role="listview" data-inset="true">
        <li data-role="fieldcontain">
            <div style="overflow:scroll" >
            <table summary="This table lists all Input of Calculation"> 
                <caption><%: Html.Label(group.grpName)%></caption> 

            <tbody>
<%   
            foreach (DBManager.OutputDesign outputDesign in group.outputDesignList)
            {
%>
                <tr>                   
<%
                //if (group.ColumnList.Count > 0 )                
                {
                    //foreach (DBManager.Column col in group.ColumnList)
                    int count = 0;
                    //print label
                    if (outputDesign.FirstColumn > 0)
                    {
                        if (count == 0)
                        {
                            if (outputDesign.Bold == 1)
                            {
%>
                    <td>
                        <b>
                        <%: outputDesign.FieldDescription%> 
                        </b> 
                    </td>
<%                           
                            }
                            else
                            {
%>
                    <td>
                        <%: outputDesign.FieldDescription%> 
                    </td>
<%             
                            }
                            count++;                          
                        }
                    }
                    //no label
                    else
                    {
                        
                    }        
                    System.Collections.Generic.List<DBManager.OutputValue> outputValueList = DBManager.DBManager.Instance.GetOutputValuesList(calc.CalculationID, outputDesign.FieldID, myOrderId);
                    foreach (DBManager.OutputValue outputV in outputValueList)                    
                    {
                        //count until first column equal count and then print
                        if (count < outputDesign.FirstColumn)
                        {
%>
                    <td>
                    </td>
<%                                    
                        }
                        else
                        {
%>
                    <td>
                        <%: Html.Label(outputV.OutputValue1)%>                  
                    </td>
<%                                    
                        }
                        count++;                        
                    } 
                } 
%>                
                </tr>
<%
            }
%>
            </tbody> 
            </table> 
            </div>
        </li>
<% 
        }
        }
        else if (orderStatus == 6)
        {
%>            
    <li data-role="fieldcontain">
        <h2>Calculation timeout</h2>
    </li>  
<%            
        }           
%>      
    </ul>
    <ul data-role="listview" data-inset="true">
        <li data-role="fieldcontain">
            <div class="example-plot" id="chart1"></div>
        </li>
    </ul>

<%
    }
%>
    
</asp:Content>